'use strict';

function numToChar(num) {
  let remainder = num%26;
  let quotient = parseInt(num/26);

  if(quotient === 0){
    return String.fromCharCode(remainder+96)
  }

  else if(quotient ===1&&remainder===0){
    return 'z';
  }

  else if(quotient > 1&&remainder===0){
    return numToChar(quotient-1) + 'z';
  }else {
    return numToChar(quotient) + String.fromCharCode(remainder+96);
  }
}

function median_to_letter(collection) {
let result;
let m;
 let arr = collection.sort((a,b)=>a-b);

 let l = arr.length/2;
 if(arr.length%2 === 0){
    m = Math.ceil((arr[l]+arr[l-1])/2);
 }else{
    m =arr[parseInt(l)];
 }
 result = numToChar(m);
 console.log(result);
 return result;
  //在这里写入代码
}
median_to_letter( [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,
  40,41,42,43,44,45,46,47,48,49,50,51,52,53]);
module.exports = median_to_letter;
